package com.ruoyi.ring.service.impl;

import cn.hutool.core.convert.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ring.domain.RingHealthPlan;
import com.ruoyi.ring.domain.dto.DatePlanInfoDTO;
import com.ruoyi.ring.mapper.RingHealthPlanMapper;
import com.ruoyi.ring.service.IRingHealthPlanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 健康计划Service业务层处理
 * 
 * @author liuwp
 * @date 2025-09-01
 */
@Service
public class RingHealthPlanServiceImpl implements IRingHealthPlanService 
{
    @Resource
    private RingHealthPlanMapper ringHealthPlanMapper;

    /**
     * 查询健康计划
     * 
     * @param id 健康计划主键
     * @return 健康计划
     */
    @Override
    public RingHealthPlan selectRingHealthPlanById(Long id)
    {
        return ringHealthPlanMapper.selectRingHealthPlanById(id);
    }

    /**
     * 查询健康计划列表
     * 
     * @param ringHealthPlan 健康计划
     * @return 健康计划
     */
    @Override
    public List<RingHealthPlan> selectRingHealthPlanList(RingHealthPlan ringHealthPlan)
    {
        return ringHealthPlanMapper.selectRingHealthPlanList(ringHealthPlan);
    }

    /**
     * 根据业务主键查询一条记录：健康计划
     *
     * @param ringHealthPlan 健康计划
     * @return 健康计划
     */
    @Override
    public RingHealthPlan selectOneRingHealthPlan(RingHealthPlan ringHealthPlan)
    {
        return ringHealthPlanMapper.selectOneRingHealthPlan(ringHealthPlan);
    }

    /**
     * 新增健康计划
     * 
     * @param ringHealthPlan 健康计划
     * @return 结果
     */
    @Override
    public int insertRingHealthPlan(RingHealthPlan ringHealthPlan)
    {
        ringHealthPlan.setCreateTime(DateUtils.getNowDate());
        return ringHealthPlanMapper.insertRingHealthPlan(ringHealthPlan);
    }

    /**
     * 修改健康计划
     * 
     * @param ringHealthPlan 健康计划
     * @return 结果
     */
    @Override
    public int updateRingHealthPlan(RingHealthPlan ringHealthPlan)
    {
        ringHealthPlan.setUpdateTime(DateUtils.getNowDate());
        return ringHealthPlanMapper.updateRingHealthPlan(ringHealthPlan);
    }

    @Override
    public int updateRingHealthPlanCondition(RingHealthPlan ringHealthPlan, RingHealthPlan ringHealthPlanCondition)
    {
        ringHealthPlan.setUpdateTime(DateUtils.getNowDate());
        return ringHealthPlanMapper.updateRingHealthPlanCondition(ringHealthPlan, ringHealthPlanCondition);
    }

    /**
     * 批量删除健康计划
     * 
     * @param ids 需要删除的健康计划主键
     * @return 结果
     */
    @Override
    public int deleteRingHealthPlanByIds(Long[] ids)
    {
        return ringHealthPlanMapper.deleteRingHealthPlanByIds(ids);
    }

    /**
     * 删除健康计划信息
     * 
     * @param id 健康计划主键
     * @return 结果
     */
    @Override
    public int deleteRingHealthPlanById(Long id)
    {
        return ringHealthPlanMapper.deleteRingHealthPlanById(id);
    }

    /**
     * 条件删除健康计划
     *
     * @param ringHealthPlan 健康计划
     * @return 结果
     */
    @Override
    public int deleteRingHealthPlanByCondition(RingHealthPlan ringHealthPlan)
    {
        return ringHealthPlanMapper.deleteRingHealthPlanByCondition(ringHealthPlan);
    }

    @Override
    public RingHealthPlan queryDatePlanInfo(DatePlanInfoDTO datePlanInfoDTO) {
        RingHealthPlan ringHealthPlan = Convert.convert(RingHealthPlan.class,datePlanInfoDTO);
        ringHealthPlan.setUserId(SecurityUtils.getUserId());
        return ringHealthPlanMapper.queryDatePlanInfo(ringHealthPlan);
    }

}
